package com.fa4j.system.app.repository.impl;

import com.fa4j.common.data.repository.impl.BaseRepositoryImpl;
import com.fa4j.common.web.model.AppType;
import com.fa4j.system.app.model.AppRole;
import com.fa4j.system.app.repository.AppRoleRepository;
import com.fa4j.system.app.repository.mapper.AppRoleMapper;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * 系统应用角色 持久化接口
 *
 * @since 2025-07-14 11:04:33
 */
@Repository
public class AppRoleRepositoryImpl extends BaseRepositoryImpl<AppRoleMapper, AppRole> implements AppRoleRepository {

    @Override
    public Optional<AppRole> findByAppAndCode(AppType appType, String code) {
        return lambdaQuery()
                .eq(AppRole::getAppType, appType)
                .eq(AppRole::getCode, code)
                .oneOpt();
    }

    @Override
    public List<AppRole> findByAppAndCodes(AppType appType, List<String> roleCodes) {
        return lambdaQuery()
                .eq(AppRole::getAppType, appType)
                .in(AppRole::getCode, roleCodes)
                .list();
    }
}
